﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Common;

namespace Ym
{
    public partial class Main : PrintPageBase
    {
        private PBLL.PConfig pbllConfig = new PBLL.PConfig();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                P_WebPath.Value = config.P_WebPath;
                P_Title.Value = config.P_Title;
                P_Footer.Value = config.P_Footer;
                P_Add.Value = config.P_Add;
                P_Name.Value = config.P_Name;
                P_Des.Value = config.P_Des;
                P_Key.Value = config.P_Key;
                P_Ipc.Value = config.P_Ipc;
                P_Fax.Value = config.P_Fax;
                P_Phone.Value = config.P_Phone;
                P_Tel.Value = config.P_Tel;
                P_WTrans.Value = config.P_WTrans.ToString();
                P_Contact.Value = config.P_Contact;
                P_WStatus.Checked = config.P_WStatus == 1 ? true : false;
            }
        }

        protected void set_Click(object sender, EventArgs e)
        {
            PModel.PConfig config = new PModel.PConfig();
            config.Id = 1;
            config.P_WebPath = P_WebPath.Value;
            config.P_Title = P_Title.Value;
            config.P_Footer = P_Footer.Value;
            config.P_Add = P_Add.Value;
            config.P_Name = P_Name.Value;
            config.P_Des = P_Des.Value;
            config.P_Key = P_Key.Value;
            config.P_Ipc = P_Ipc.Value;
            config.P_Fax = P_Fax.Value;
            config.P_Phone = P_Phone.Value;
            config.P_Tel = P_Tel.Value;
            config.P_WTrans = int.Parse(P_WTrans.Value);
            config.P_Contact = P_Contact.Value;
            config.P_WStatus = P_WStatus.Checked ? 1 : 0;
            if (pbllConfig.SetConfig(config))
            {
                JscriptPrint("保存设置成功！", "Main.aspx", "Success");
            }
            else
            {
                JscriptPrint("保存设置失败！", "Main.aspx", "Error");
            }
        }
    }
}